package fr.labri.harmony.analysis.jsep.results.filter;

import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import fr.labri.harmony.analysis.jsep.results.LoadRules;

public class MigrationLength extends ResultFilter {

	@Override
	public void computeResult(ResultSet rs) throws SQLException, IOException {
		rs.first();
		List<Integer> correct_length = new ArrayList<Integer>();
		List<Integer> wrong_length = new ArrayList<Integer>();

		while (rs.next()){			
			String source = rs.getString("NAME");
			String target = rs.getString("MIGRATION_LIB_TO");
			if(target!=null) {
				int length = rs.getInt("migration_length");
				if(LoadRules.isTrueRule(source, target)) {
					correct_length.add(length);
				}
				else {
					wrong_length.add(length);
				}
			}
		}
		displayList("Length ",correct_length,wrong_length);
	}

}
